<?php

namespace App\Models\Game\Pay\Order;

use App\Models\Game\Model;
use App\Models\Game\Platform\Org;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Transfer extends Model
{

    /**
     * 数据表名称
     *
     * @var string
     */
    protected $table = 't_pay_order';

    /**
     * 进行类型转换的字段
     *
     * @var array
     */
    protected $casts = [
        'created' => 'timestamp',
        'updated' => 'timestamp',
        'usd' => 'array',
        'msg' => 'array',
    ];

    /**
     * 状态【创建订单】
     *
     * @var integer
     */
    const STATUS_INIT = 1;

    /**
     * 状态【支付成功】
     *
     * @var integer
     */
    const STATUS_SUCCEED = 2;

    /**
     * 状态【支付失败】
     *
     * @var integer
     */
    const STATUS_FAILED = 3;

    /**
     * 类型【转入订单】
     *
     * @var integer
     */
    const TRANSFER_TYPE_IN = 1;

    /**
     * 类型【转出订单】
     *
     * @var integer
     */
    const TRANSFER_TYPE_OUT = 2;

    /**
     * 获得平台信息
     *
     * @return BelongsTo
     */
    public function org(): BelongsTo
    {
        return $this->belongsTo(Org::class, 'plat_code', 'code')->withTrashed();
    }
}
